﻿using System;
using System.Data;
using System.Windows.Forms;
using Telerik.WinControls.UI;
using Zvezda.FSO2.DB;


namespace FSO
{
    public partial class UserControlSearchNSIService : UserControl, InterfaceSearchControl
    {
        private bool _openOnDblClick;

        public UserControlSearchNSIService()
        {
            InitializeComponent();
            radGridViewList.MultiSelect = true;
        }

        public bool OpenOnDoubleClick
        {
            get
            {
                return _openOnDblClick;
            }
            set
            {
                _openOnDblClick = value;
            }
        }

        public bool EnableFiltering
        {
            get
            {
                return radGridViewList.EnableFiltering;
            }
            set
            {
                radGridViewList.EnableFiltering = value;
            }
        }

        public DataRow SelectedRow
        {
            get { throw new NotImplementedException(); }
        }

        public DataSet OwnerDataSet
        {
            get { return dataSetFSO1; }
            set { dataSetFSO1 = (DataSetFSO)value; }
        }

        public GridViewSelectedRowsCollection SelectedRows
        {
            get { return radGridViewList.SelectedRows; }
        }

        public void RefreshList()
        {
            vieW_SEARCH_NSI_SERVICETableAdapter1.Fill(dataSetFSO1.VIEW_SEARCH_NSI_SERVICE);
        }

        private void InitializeGridView()
        {
            GridViewTextBoxColumn colCode = new GridViewTextBoxColumn("CODE", dataSetFSO1.VIEW_SEARCH_NSI_SERVICE.CODEColumn.ColumnName);
            colCode.HeaderText = "Код";

            GridViewTextBoxColumn colFName = new GridViewTextBoxColumn("FULL_NAME", dataSetFSO1.VIEW_SEARCH_NSI_SERVICE.FULL_NAMEColumn.ColumnName);
            colFName.HeaderText = "Полное наименование";

            GridViewTextBoxColumn colSName = new GridViewTextBoxColumn("SHORT_NAME", dataSetFSO1.VIEW_SEARCH_NSI_SERVICE.SHORT_NAMEColumn.ColumnName);
            colSName.HeaderText = "Короткое наименование";

            radGridViewList.MasterTemplate.Columns.Clear();
            radGridViewList.MasterTemplate.Columns.Add(colCode);
            radGridViewList.MasterTemplate.Columns.Add(colFName);
            radGridViewList.MasterTemplate.Columns.Add(colSName);

            radGridViewList.DataSource = dataSetFSO1.VIEW_SEARCH_NSI_SERVICE;
        }

        private void UserControlSearchNSIService_Load(object sender, EventArgs e)
        {
            InitializeGridView();
            RefreshList();
        }

    }
}
